<template>
	<view class="resultTask">
		<uni-nav-bar color="#ffffff" background-color="#00aded" :statusBar="true" title="运输订单" fixed="true" left-icon="left" left-text="返回" @clickLeft="back"></uni-nav-bar>
		<view class="resultTask_top">
			<view class="" style="margin-top: 10rpx; margin-bottom: 10rpx"></view>
			<uni-section title="运单一览" type="line" title-font-size="20px">
				<dil-search :columnData="options.columnDataList" @onSearch="onSearch" v-if="options.columnDataList.length > 0" class="dilSearch"></dil-search>
				<dil-card class="dilCard" @emitEvent="emitEvent" v-bind.sync="options"></dil-card>
			</uni-section>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			formValue: {},
			formCountValue: {},
			form_weight: {},
			options: {
				requestUrl: '/api/v1/tms/getTransOrderList?apiId=627',
				requestQuery: {},
				cardSlotList: [
					{
						label: '暂停开始',
						icon: 'plus',
						emitEvent: 'pauseClickStart'
					},
					{
						label: '暂停结束',
						icon: 'plus',
						emitEvent: 'pauseClickEnd'
					}
				],
				columnDataList: [],
				totalNum: 0,
				rowDataList: []
			},
			routeParams: {}
		};
	},
	onLoad(options) {
		console.log(options, 'op');
		this.routeParams = options;
	},
	onShow() {
		this.getOrderSection();
	},
	mounted() {
		this.getOrderSectionDebounce = this.Tool.debounce((data) => {
			this.getOrderSection(data);
		}, 500);
	},
	methods: {
		pauseClickStart(item) {
			let that = this;
			uni.showModal({
				cancelText: '取消',
				confirmText: '确认',
				title: '确认暂停开始',
				success: (res) => {
					if (res.confirm) {
						item.pauseOrderStatus = '开始';
						that.pauseClick(item);
					}
				}
			});
		},
		pauseClickEnd(item) {
			let that = this;
			uni.showModal({
				cancelText: '取消',
				confirmText: '确认',
				title: '确认暂停结束',
				success: (res) => {
					if (res.confirm) {
						item.pauseOrderStatus = '结束';
						that.pauseClick(item);
					}
				}
			});
		},
		async pauseClick(data) {
			const res = await this.$myRequest({
				url: '/api/v1/tms/updateTransOrder',
				data: data
			}).catch((err) => {
				uni.showToast({
					duration: 2000,
					title: err,
					icon: 'error'
				});
			});
			if (res.data.status == 'succeed') {
				uni.showToast({
					title: res.data.message,
					duration: 2000,
					icon: 'success'
				});
				this.getOrderSectionDebounce({});
			} else {
				uni.showToast({
					title: res.data.message,
					duration: 2000,
					icon: 'error'
				});
			}
		},
		onSearch(item) {
			this.getOrderSectionDebounce(item);
		},
		back() {
			uni.switchTab({
				url: '/pages/index/index'
			});
		},
		async getOrderSection(item = {}) {
			item = { ...item, ...this.routeParams };
			this.options.requestQuery = JSON.parse(JSON.stringify(Object.assign(this.options.requestQuery, item)));
		},
		emitEvent(eventName, cardItem) {
			this[eventName](cardItem);
		},
		async editActualWeightSubmit() {
			this.form_weight.scFlag = 1;
			const res = await this.$myRequest({
				url: '/api/v1/tms/updateTransOrder',
				data: this.form_weight
			}).catch((err) => {
				uni.showToast({
					duration: 2000,
					title: err,
					icon: 'error'
				});
			});
			if (res.data.status == 'succeed') {
				uni.showToast({
					title: res.data.message,
					duration: 2000,
					icon: 'success'
				});
				this.getOrderSectionDebounce({});
			} else {
				uni.showToast({
					title: res.data.message,
					duration: 2000,
					icon: 'error'
				});
			}
			this.$refs.editActualWeight_popup.close();
		},
		resendCount(cardItem) {
			let that = this;
			this.formCountValue = cardItem;
			this.$refs.editActualCount_popup.open('center');
		},
		async updCountResult() {
			const res = await this.$myRequest({
				url: '/api/v1/tms/updCountResult',
				data: this.formCountValue
			}).catch((err) => {
				uni.showToast({
					duration: 2000,
					title: err,
					icon: 'none'
				});
			});
			if (res.data.status == 'succeed') {
				uni.showToast({
					duration: 2000,
					title: '操作成功',
					icon: 'success'
				});
				this.getOrderSectionDebounce();
				this.closePopup();
			} else {
				uni.showToast({
					duration: 2000,
					title: res.data.message,
					icon: 'none'
				});
			}
		}
	}
};
</script>

<style lang="scss" scoped>
.resultTask {
	width: 100vw;
	height: 100%;
	background-color: #f5f5f5;
	display: flex;
	justify-content: center;
	align-items: center;
	flex-direction: column;
	&_top {
		width: 100vw;
		height: 100%;
		.uni-section {
			width: 100vw;
			.dilSearch {
				width: 100%;
			}
			/deep/.uni-section-content {
				display: flex;
				justify-content: center;
				align-items: center;
				flex-direction: column;
				.noTip {
					width: 100vw;
					height: 10vh;
					display: flex;
					justify-content: center;
					align-items: center;
					font-weight: 700;
					font-size: 60rpx;
					color: #000;
				}
			}
		}
	}
	.resultTask_top_result {
		margin-top: 20rpx;
		.scroll-Y {
			height: 90vh;
		}
	}
	&_main {
		margin-top: 20rpx;
	}
	&_middle {
		margin-top: 20rpx;
		.uni-section {
			width: 100vw;
			/deep/.uni-section-content {
				display: flex;
				justify-content: center;
				align-items: center;
			}
			/deep/.uni-card {
				border-radius: 40rpx;
				.buttonClass {
					margin-top: 20rpx;
					display: flex;
					justify-content: center;
					align-items: center;
				}
				.button {
					border-radius: 40rpx;
				}
			}
		}
	}
	&_floot {
		width: 100vw;
		background-color: #fff;
		margin-top: 20rpx;
		margin-bottom: 20rpx;
		border-radius: 20rpx;
	}
	.editActualWeight {
		&_main {
			.tip {
				font-size: 32rpx;
				font-weight: 500;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				text {
					margin-top: 20rpx;
				}
			}
			.importData {
				margin-top: 20rpx;
				font-size: 32rpx;
				font-weight: 700;
				color: #ff0000;
				text {
					padding: 20rpx;
				}
			}
			.dilForm {
				width: 90%;
				margin-left: 20rpx;
				/deep/.uni-forms .uni-forms-item .uni-forms-item__label {
					font-weight: 700;
					color: #000;
					font-size: 32rpx;
				}
				/deep/.uni-forms .uni-forms-item .uni-forms-item__content {
					font-weight: 700;
					color: #000;
					font-size: 32rpx;
				}

				/deep/.uni-forms .uni-forms-item .uni-forms-item__content .uni-input-placeholder {
					font-weight: 700;
					// color: #ff0000;
					font-size: 28rpx;
				}
				/deep/.uni-forms .uni-forms-item .uni-forms-item__content .uni-input-input:disabled {
					font-weight: 700;
					color: #ff0000;
					font-size: 28rpx;
				}
				// display: flex;
				// justify-content: center;
				// align-items: center;
			}
		}
	}
	.editActualCount {
		&_main {
			.tip {
				font-size: 32rpx;
				font-weight: 500;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				text {
					margin-top: 20rpx;
				}
			}
			.importData {
				margin-top: 20rpx;
				font-size: 32rpx;
				font-weight: 700;
				color: #ff0000;
				text {
					padding: 20rpx;
				}
			}
			.dilForm {
				width: 90%;
				margin-left: 20rpx;
				/deep/.uni-forms .uni-forms-item .uni-forms-item__label {
					font-weight: 700;
					color: #000;
					font-size: 32rpx;
				}
				/deep/.uni-forms .uni-forms-item .uni-forms-item__content {
					font-weight: 700;
					color: #000;
					font-size: 32rpx;
				}

				/deep/.uni-forms .uni-forms-item .uni-forms-item__content .uni-input-placeholder {
					font-weight: 700;
					// color: #ff0000;
					font-size: 28rpx;
				}
				/deep/.uni-forms .uni-forms-item .uni-forms-item__content .uni-input-input:disabled {
					font-weight: 700;
					color: #ff0000;
					font-size: 28rpx;
				}
				// display: flex;
				// justify-content: center;
				// align-items: center;
			}
		}
	}
}
</style>
